import javax.swing.*;

/**
 * @classname 技能类
 * @Author 姬如千泷
 * @Date 2021/5/11  17:44
 * @Version 1.0
 */
public class MySkill {
    MyCharacter ct_label;//当前角色
    int direction =1;
    public MySkill(MyCharacter ct_label) {
        this.ct_label = ct_label;
        if(ct_label.juage_lr)
            direction=-direction;
    }

    public void broach() {//拔刀斩
        if(ct_label.juage_lr)
            new Mybroach(1).start();
        else new Mybroach(2).start();
    }
    public void gFlash() {//鬼影闪
        if(ct_label.juage_lr)
            new MygFlash(3).start();
        else new MygFlash(4).start();
    }
    public void godX() {//圣灵斩击
        if(ct_label.juage_lr)
            new MygodX(6).start();
        else new MygodX(5).start();
    }
    class MygFlash extends Thread {//鬼影闪线程
        int i;
        public MygFlash(int i) {
            this.i = i;
        }
        @Override
        public void run() {
            int skill_x=0,skill_y=0;//由于分辨率等的差异，维护一组自己的坐标
            if(ct_label.juage_lr)
                skill_x=ct_label.ct_x-40;
            else skill_x=ct_label.ct_x-30;
            skill_y =ct_label.ct_y-40;
            try {
                for (int i = 1; i < 7; i++) {
                    ct_label.setIcon(juage(i, this.i));
                    ct_label.setBounds(skill_x,skill_y,300,300);
                    if (i == 1) { Thread.sleep(800);}
                    if(i==6){
                        new MySpecial(ct_label).seam();
                        Thread.sleep(1000);
                    }
                    if(i==3){ skill_x+=200*direction; }
                    if(i==4){skill_x+=200*direction; }

                    Thread.sleep(100);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (ct_label.juage_lr)
                ct_label.setIcon(DateCenter.lstand);
            else ct_label.setIcon(DateCenter.rstand);
            ct_label.juage_skill = false;//标志位改变
            ct_label.ct_x+=400*direction;
            ct_label.setBounds(ct_label.ct_x,ct_label.ct_y,150,200);//恢复原坐标及大小
        }
    }

    class Mybroach extends Thread {//拔刀斩线程
        int i;
        public Mybroach(int i) {
            this.i = i;
        }
        @Override
        public void run() {
            int skill_x=0,skill_y=0;//由于分辨率等的差异，维护一组自己的坐标
            if(ct_label.juage_lr)
            skill_x=ct_label.ct_x-80;
            else skill_x=ct_label.ct_x-50;
            skill_y =ct_label.ct_y-70;
            try {
                for (int i = 1; i < 8; i++) {
                    ct_label.setIcon(juage(i, this.i));
                    ct_label.setBounds(skill_x,skill_y,300,300);
                    if (i == 7) {
                        if(ct_label.juage_lr)
                        new Mybullet(skill_x-80,skill_y-80,ct_label,2).start();
                        else new Mybullet(skill_x+30,skill_y-80,ct_label,2).start();
                        Thread.sleep(600);
                    }
                    Thread.sleep(100);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (ct_label.juage_lr)
                ct_label.setIcon(DateCenter.lstand);
            else ct_label.setIcon(DateCenter.rstand);
            ct_label.juage_skill = false;//标志位改变
            ct_label.setBounds(ct_label.ct_x,ct_label.ct_y,150,200);//恢复原坐标及大小
        }
    }
    class MygodX extends Thread {//圣灵斩击线程
        int i;
        public MygodX(int i) {
            this.i = i;
        }
        @Override
        public void run() {
            int skill_x=0,skill_y=0;//由于分辨率等的差异，维护一组自己的坐标
            if(ct_label.juage_lr)
                skill_x=ct_label.ct_x-145;
            else skill_x=ct_label.ct_x-45;
            skill_y =ct_label.ct_y-75;
            try {
                for (int i = 1; i < 10; i++) {
                    ct_label.setIcon(juage(i, this.i));
                    ct_label.setBounds(skill_x,skill_y,300,300);
                    if(i==6){
                        new MySpecial(ct_label).crack();
                        Thread.sleep(800);
                    }
                    Thread.sleep(50);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (ct_label.juage_lr)
                ct_label.setIcon(DateCenter.lstand);
            else ct_label.setIcon(DateCenter.rstand);
            ct_label.juage_skill = false;//标志位改变
            ct_label.setBounds(ct_label.ct_x,ct_label.ct_y,150,200);//恢复原坐标及大小
        }
    }
    public ImageIcon juage(int i, int t) {
        if (t == 1) {//绘制向左拔刀斩
            switch (i) {
                case 1:
                    return DateCenter.lbroach1;
                case 2:
                    return DateCenter.lbroach2;
                case 3:
                    return DateCenter.lbroach3;
                case 4:
                    return DateCenter.lbroach4;
                case 5:
                    return DateCenter.lbroach5;
                case 6:
                    return DateCenter.lbroach6;
                case 7:
                    return DateCenter.lbroach7;
                default:
                    return null;
            }
        } else if(t==2){//绘制向右拔刀斩
            switch (i) {
                case 1:
                    return DateCenter.rbroach1;
                case 2:
                    return DateCenter.rbroach2;
                case 3:
                    return DateCenter.rbroach3;
                case 4:
                    return DateCenter.rbroach4;
                case 5:
                    return DateCenter.rbroach5;
                case 6:
                    return DateCenter.rbroach6;
                case 7:
                    return DateCenter.rbroach7;
                default:
                    return null;
            }
        }
        else if(t==3){
            switch (i) {
                case 1:
                    return DateCenter.lgFlash1;
                case 2:
                    return DateCenter.lgFlash2;
                case 3:
                    return DateCenter.lgFlash3;
                case 4:
                    return DateCenter.lgFlash4;
                case 5:
                    return DateCenter.lgFlash5;
                case 6:
                    return DateCenter.lgFlash6;
                case 7:
                default:
                    return null;
            }
        }else if(t==4){
            switch (i) {
                case 1:
                    return DateCenter.rgFlash1;
                case 2:
                    return DateCenter.rgFlash2;
                case 3:
                    return DateCenter.rgFlash3;
                case 4:
                    return DateCenter.rgFlash4;
                case 5:
                    return DateCenter.rgFlash5;
                case 6:
                    return DateCenter.rgFlash6;
                case 7:
                default:
                    return null;
            }
        }
        else if(t==5){
            switch (i) {
                case 1:
                    return DateCenter.rgodx1;
                case 2:
                    return DateCenter.rgodx2;
                case 3:
                    return DateCenter.rgodx3;
                case 4:
                    return DateCenter.rgodx4;
                case 5:
                    return DateCenter.rgodx5;
                case 6:
                    return DateCenter.rgodx6;
                case 7:
                    return DateCenter.rgodx7;
                case 8:
                    return DateCenter.rgodx8;
                case 9:
                    return DateCenter.rgodx9;
                default:
                    return null;
            }
        }
        else {
            switch (i) {
                case 1:
                    return DateCenter.lgodx1;
                case 2:
                    return DateCenter.lgodx2;
                case 3:
                    return DateCenter.lgodx3;
                case 4:
                    return DateCenter.lgodx4;
                case 5:
                    return DateCenter.lgodx5;
                case 6:
                    return DateCenter.lgodx6;
                case 7:
                    return DateCenter.lgodx7;
                case 8:
                    return DateCenter.lgodx8;
                case 9:
                    return DateCenter.lgodx9;
                default:
                    return null;
            }
        }
    }
}